﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Harmonic.Models;
using Harmonic.ReadModel;

namespace Harmonic.Controllers
{
    public class ProductController : Controller
    {
        //
        // GET: /Product/

        public ActionResult Index()
        {
            return View();
        }

        //
        // GET: /Product/Details/5
        [HttpGet]
        public ActionResult Details(int ProductId)
        {
            ReadModel.Queries query = new ReadModel.Queries();
            return View(query.SelectProduct(ProductId));
        }

        // GET: /Product/AddToCart/5
        [HttpGet]
        public ActionResult AddToCart(int ProductId)
        {
            if (Session["Cart"] == null)
            {
                Session.Add("Cart", new List<Product>());
            }

            List<Product> products = (List<Product>)Session["Cart"];
            Product product = new Product() { ProductId = ProductId, ProductName = "name" };
            products.Add(product);

            return View(product);
        }


    }
}
